package com.nulldev.util.web.YouTubeExtractor.items;

public class YouTubeVideoHeatmap {

	/*
	 * layout: { "heatmapPointDuration": LONG "heatmapPointStartMillis": LONG
	 * "heatmapIntensity": FLOAT "isPriorityPoint": BOOLEAN }
	 */

	public static final int ENTRY_SET_SIZE = 4;
	private final Object[][] heatmap_data;

	public YouTubeVideoHeatmap(final Object[][] data) {
		this.heatmap_data = data;
	}

	public Object[][] getHeatmap() {
		return this.heatmap_data;
	}

	public Object[] getHeatmapSet(final int index) {
		if (index < 0 || index >= this.heatmap_data.length)
			return null;
		return this.heatmap_data[index];
	}

	public static enum HeatmapDataType {
		POINT_DURATION,
		POINT_START_MILLIS,
		INTENSITY,
		IS_PRIORITY_DATA
	}

	public Object getHeatmapData(final HeatmapDataType type, final int index) {
		if (index < 0 || index >= this.heatmap_data.length)
			return null;
		switch (type) {
			case INTENSITY:
				return this.heatmap_data[index][2];
			case POINT_START_MILLIS:
				return this.heatmap_data[index][1];
			case POINT_DURATION:
				return this.heatmap_data[index][0];
			case IS_PRIORITY_DATA:
				return this.heatmap_data[index][3];
			default:
				throw new IllegalArgumentException("Unknown data type: " + type);
		}
	}

	public int getSize() {
		return this.heatmap_data.length;
	}
}
